// Learn cc.Class:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/class/index.html
// Learn Attribute:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/reference/attributes/index.html
// Learn life-cycle callbacks:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/life-cycle-callbacks/index.html

cc.Class({
    extends: cc.Component,

    properties: {
        labLotteryName: cc.Label,   //订单名
        labMoney: cc.Label, //订单价格
        labIsuse: cc.Label, //订单期数
        labType: cc.Label,  //订单类型
        labState: cc.Label,  //订单状态
        spWin: cc.Node,  //中奖显示
        labYMD: cc.Label,  //年月日显示

    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    init: function(data){
        if(data !=null){
            this.labLotteryName.string = data.LotteryName;
            var isuse =data.IsuseNum == null ? "":data.IsuseNum;
            this.labIsuse.string = isuse ? '第'+isuse+'期' : "";
            this.labType.string = data.type;
            this.labMoney.string = data.Money.toString() + "元宝";
            this.labYMD.string = data.Year+'-'+data.Month+'-'+data.Day;

            //订单状态
            if(data.State == 14)
            {
                this.labState.node.active = false;
                this.spWin.active = true;
            }
            else
            {
                this.labState.node.active = true;
                this.spWin.active = false;
                this.labState.string = LotteryUtils.getOrderStatusByStatus(data.State);
                if(LotteryUtils.getOrderStatusByStatus(data.State) =='未中奖'){
                    this.labState.node.color =new cc.Color(59,133,255);    
                }else{
                    this.labState.node.color =new cc.Color(116,116,116);       
                }
            }    
        }
    },

    // update (dt) {},
});
